<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of welcome
 *
 * @author Obi
 */
class Admin_provinsi extends MY_Controller {

    function __construct() {
        parent::__construct();

        $cek_admin = $this->session->userdata('cek_admin');
        if (!$cek_admin)
            redirect("admin");

        $this->mprovinsi = new M_provinsi();
    }

    function index() {

        $data['title'] = 'Daftar Provinsi';
        $data['list'] = $this->mprovinsi->get();

        $data['isi'] = 'isi';
        $this->load->view('template_admin', $data);
    }

    function tambah() {
        $data['title'] = 'Tambah Data Provinsi';
        $data['id'] = "";
        $data['nama_provinsi'] = "";
        $data['status'] = "1";

        $data['isi'] = 'form';
        $this->load->view('template_admin', $data);
    }

    function edit($id = NULL) {

        $data['title'] = 'Ubah Data Provinsi';
        $dt = $this->mprovinsi->where("id = '$id'")->get();

        $data['id'] = $dt->id;
        $data['nama_provinsi'] = $dt->nama_provinsi;
        $data['status'] = $dt->status;

        $data['isi'] = 'form';
        $this->load->view('template_admin', $data);
    }

    function delete($id) {
        $this->mprovinsi->delete($id);
        redirect("admin_provinsi");
    }

    function simpan() {
        $id = $this->input->post('id');

        if ($id == "") {
            $this->mprovinsi->insert($data);
        } else {
            $this->mprovinsi->update($data, $id);
        }

        redirect("admin_provinsi");
    }

}

?>
